package com.elong.businesstravel.protocol.login;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.Header;
import org.json.JSONArray;
import org.json.JSONObject;

import com.elong.businesstravel.entitys.RedPurse;
import com.elong.businesstravel.protocol.baseresponse.BaseELongJsonHttpResponse;

public class MemberGetUseCouponsResponse extends BaseELongJsonHttpResponse {

	protected List<RedPurse> redPurses = new ArrayList<RedPurse>();

	@Override
	public void onSuccess(int statusCode, Header[] headers,
			JSONObject mainJsonObject) throws Throwable {

		JSONObject responseJsonObject = mainJsonObject
				.optJSONObject("response");
		if (null != responseJsonObject) {
			JSONArray scoreJSONArray = responseJsonObject.optJSONArray("score");
			if (null != scoreJSONArray) {
				for (int i = 0; i < scoreJSONArray.length(); i++) {
					JSONObject itemJsonObject = scoreJSONArray.optJSONObject(i);
					if (null != itemJsonObject) {
						RedPurse redPurse = new RedPurse();
						redPurse.id = itemJsonObject.optString("id", "");
						redPurse.uid = itemJsonObject.optString("uid", "");
						redPurse.status = itemJsonObject
								.optInt("status", -1);
						redPurse.reason = itemJsonObject
								.optString("reason", "");
						redPurse.jointime = itemJsonObject.optString(
								"jointime", "");
						redPurse.endtime = itemJsonObject.optString("endtime",
								"");
						redPurse.value = itemJsonObject.optString("value", "");
						redPurse.typeinfo = itemJsonObject.optString(
								"typeinfo", "");
						redPurse.addtime = itemJsonObject.optString("addtime",
								"");
						redPurse.addscore = itemJsonObject.optString(
								"addscore", "");
						redPurses.add(redPurse);
					}
				}
			}
		}

	}
}
